package com.zkingsoft.codeApi;

/**
 * 代码文件模型
 * 
 * @author Matrix-J
 *
 */
public class TemplateModel {

	public static TemplateModel getTemplateModel(ModelType modelType) {

		TemplateModel templateModel = new TemplateModel();

		if (modelType.equals(ModelType.JAVA_BEAN)) {

			templateModel.setModelType(ModelType.JAVA_BEAN);
			templateModel.setExtensionName(".java");
			templateModel.setTemplateName("javaBean.ftl");

		} else if (modelType.equals(ModelType.MYBATIS_DAO)) {
			templateModel.setModelType(ModelType.MYBATIS_DAO);
			templateModel.setSuffix("Dao");
			templateModel.setExtensionName(".java");
			templateModel.setTemplateName("dao.ftl");

		} else if (modelType.equals(ModelType.MYBATIS_DAO_IMPL)) {

			templateModel.setModelType(ModelType.MYBATIS_DAO_IMPL);
			templateModel.setExtensionName(".xml");
			templateModel.setTemplateName("daoImpl.ftl");

		} else if (modelType.equals(ModelType.SERVICE)) {

			templateModel.setModelType(ModelType.SERVICE);
			templateModel.setSuffix("Service");
			templateModel.setExtensionName(".java");
			templateModel.setTemplateName("service.ftl");

		} else if (modelType.equals(ModelType.SERVICE_IMPL)) {

			templateModel.setModelType(ModelType.SERVICE_IMPL);
			templateModel.setSuffix("ServiceImpl");
			templateModel.setExtensionName(".java");
			templateModel.setTemplateName("serviceImpl.ftl");

		} else if (modelType.equals(ModelType.ACTION)) {

			templateModel.setModelType(ModelType.ACTION);
			templateModel.setSuffix("Action");
			templateModel.setExtensionName(".java");
			templateModel.setTemplateName("action.ftl");

		} else if (modelType.equals(ModelType.LIST)) {
			templateModel.setSuffix("-list");
			templateModel.setModelType(ModelType.LIST);
			templateModel.setExtensionName(".jsp");
			templateModel.setTemplateName("list.ftl");
		} else if (modelType.equals(ModelType.FORM)) {
			templateModel.setSuffix("-form");
			templateModel.setModelType(ModelType.FORM);
			templateModel.setExtensionName(".jsp");
			templateModel.setTemplateName("form.ftl");
		}

		return templateModel;
	}

	/**
	 * 模型文件类型
	 */
	ModelType modelType;

	/**
	 * 文件保存路径
	 */
	private String savePath;

	/**
	 * 生成文件后缀
	 */
	private String suffix;

	/**
	 * 生成文件前缀
	 */
	private String prefix;

	/**
	 * 文件扩展名称
	 */
	private String extensionName;

	/**
	 * 模板名称
	 */
	private String templateName;

	public ModelType getModelType() {
		return modelType;
	}

	public void setModelType(ModelType modelType) {
		this.modelType = modelType;
	}

	public String getSavePath() {
		return savePath;
	}

	public void setSavePath(String savePath) {
		this.savePath = savePath;
	}

	public String getSuffix() {
		return suffix;
	}

	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}

	public String getPrefix() {
		return prefix;
	}

	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}

	public String getExtensionName() {
		return extensionName;
	}

	public void setExtensionName(String extensionName) {
		this.extensionName = extensionName;
	}

	public String getTemplateName() {
		return templateName;
	}

	public void setTemplateName(String templateName) {
		this.templateName = templateName;
	}

}
